<template>
	<view class="u-page">
		<view v-for="(item, index) in list" :key="index">
			<u-cell customStyle="background:#fff;" :title="item.realname" :isLink="true" @click="showSeller(item)">
				<view slot="label">
					<text>{{item.mobile}}</text>
				</view>
				<view slot="value">
					<text v-if="item.status=='normal'" class="tag-info">正常</text>
					<text v-if="item.status=='hidden'" class="tag-danger">禁用</text>
				</view>
			</u-cell>
		</view>
		<u-empty v-if="list.length==0" text="没有销售经理!" mode="search" marginTop="50"></u-empty>
		<view class="plusbtn" @click="$navigateTo" data-url="admin/addjingli">
			<u-icon name="plus" size="24" color="#fff"></u-icon>
		</view>
		<u-popup :show="showDetail" @close="showDetail=false" mode="center" :round="4" customStyle="width:80%;padding:30rpx 0;">
			<view class="detail">
				<view class="itx">姓名：{{detail.realname}}</view>
				<view class="itx">电话：{{detail.mobile}} <text @click="call(detail)" style="white-space: nowrap;margin-left: 6rpx;" class="tag-info">拨打</text></view>
				<u-button type="warning" size="small" @click="store" customStyle="margin-top:40rpx;margin-bottom:20rpx;">店铺</u-button>
				<u-button type="success" size="small" @click="shouyi" customStyle="margin-bottom:20rpx;">收益</u-button>
				<u-button color="#ad79af" size="small" @click="jiesuan" customStyle="margin-bottom:20rpx;">结算</u-button>
				<u-button type="primary" size="small" @click="edit" customStyle="margin-bottom:20rpx;">修改</u-button>
				<u-button type="error" size="small" @click="del">删除</u-button>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {methods} from '@/utils/methods.js';
	export default {
		data() {
			return {
				list:[],
				detail:'',
				showDetail:false
			}
		},
		onPullDownRefresh() {
			this.getData(true);
		},
		onShow() {
			this.getData();
		},
		methods: {
			...methods,
			shouyi:function(){
				this.$navigateTo('admin/shouyi?seller_id='+this.detail.id);
			},
			jiesuan:function(){
				this.$navigateTo('admin/jiesuan?seller_id='+this.detail.id);
			},
			store:function(){	
				this.showDetail=false;
				this.$navigateTo('admin/jinglistore?seller_id='+this.detail.id);
			},
			edit:function(){
				this.showDetail=false;
				uni.setStorageSync('seller',this.detail);
				this.$navigateTo('admin/addjingli');
			},
			del:function(){
				uni.showModal({
					content:'确认要删除该销售经理吗？',
					success: (res) => {
						if(res.confirm){
							this.$get("admin/channel/delSeller",{id:this.detail.id},true).then(res=>{
								this.showDetail=false;
								this.getData();
							});		
						}
					},
				});	
			},
			showSeller:function(detail){
				this.detail=detail;
				this.showDetail=true;
			},
			getData:function(pulldown=false){
				this.$get("admin/channel/listSeller").then(res=>{
					if(pulldown){
						uni.stopPullDownRefresh();
					}			
					this.list=res;	
				});		
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #eeeeee;
	}
	.plusbtn{
		position: fixed;
		bottom: 20rpx;
		right: 20rpx;
		background-color: #3f9ad7;
		border-radius: 50%;
		padding: 8rpx;
		z-index: 999;
	}
	.detail{
		padding: 20rpx;
		text-align: center;
		.itx{
			font-size: 28rpx;
			text-align: left;
			margin-bottom: 20rpx;
		}
		.itx:last-child{
			margin-bottom: 0rpx;
		}
		.img{
			width: 100%;
			height: 300rpx;
			margin-bottom: 10rpx;
		}
	}
</style>